<%@ page pageEncoding="UTF-8" contentType="text/html; charset=utf-8"  %>
<html>
<head>
<%@ include file="/user/load_user_with_redirect.jsp" %>
<%
	String id = request.getParameter("id");
	org.languageguide.readings.Reading reading = new org.languageguide.readings.ReadingImpl(id);
	String text = reading.getWordWrappedReading();
	String times = reading.getTimes();
	String soundPath = reading.getSoundPath();
	//Integer highestIdProcessed = reading.getHighestIdProcessed();
	if (soundPath == null){
		// forward to page to upload sound file
	}
	org.languageguide.versioncontrol.LockingVersionControl readingVersionControl = (org.languageguide.versioncontrol.LockingVersionControl)reading;
	
	boolean checkedOut = readingVersionControl.checkout(user);
	if (!checkedOut){
		System.out.println("redirect: this sucker is checked out");
		return;
	}
%>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="scripts/sound.js"></script>
<script type="text/javascript">
	var id = <%= id %>;
	var times = new Array(<%= times %>);
	//var highestIdProcessed = <= highestIdProcessed >;
</script>
</head>
<body onkeydown="keyevent(event)" onLoad="init()">
      <audio id="player" controls src="<%= soundPath %>"></audio>      
  <button name="begin" id="begin" onClick="javascript:play()">Begin</button>
  <button disabled name="pause" id="pause" onClick="javascript:pause()">Pause</button>
  <button disabled style="margin-left: 50px;" name="save" id="save" onClick="javascript:save()">Save</button>
  <button disabled name="continue" id="continue" onClick="javascript:continueOn()">Continue</button>
  <button name="exit" id="exit" onClick="javascript:tryToExit()">Exit</button>
  <div style="display:inline; width: 198px;" id="message">&nbsp;</div>
  <p style="clear:both;"></p>
<%= text %>
</body>
</html>